const express = require('express');
const router = new express.Router();

/**
 * @param {Object} options
 * @param {} options.code 编号
 * @param {} options.name 名称
 * @param {} options.beginStartTime 启用日期 - 开始
 * @param {} options.endStartTime 启用日期 - 结束
 * @param {} options.status 状态
 * @param {} options.warrantyPolicyType 整车索赔政策类型
 * @param {} options.pageSize 每页数据量
 * @param {} options.pageIndex 指定页
 * @param {} options.sortField 排序字段
 * @param {} options.isDesc 倒序排列
 * @throws {Error}
 * @return {Promise}
 */
router.get('/', async(req, res, next) => {
    const options = {
        code: req.query.code,
        name: req.query.name,
        beginStartTime: req.query.beginStartTime,
        endStartTime: req.query.endStartTime,
        status: req.query.status,
        warrantyPolicyType: req.query.warrantyPolicyType,
        pageSize: req.query.pageSize,
        pageIndex: req.query.pageIndex,
        sortField: req.query.sortField,
        isDesc: req.query.isDesc
    };
    const data = {
        message: 'message',
        payload: {
            content: [
                {
                    id: 'id197',
                    warrantyPolicyId: 'warrantyPolicyId198',
                    rowVersion: 'rowVersion',
                    options: [
                        'update',
                        'abandon',
                        'enable'
                    ],
                    code: 'code199',
                    name: 'name200',
                    startTime: '2019-06-29T05:56:31Z',
                    status: 1,
                    warrantyPolicyType: 1,
                    warrantyMileage: 1,
                    warrantyMonth: 1,
                    dealerId: 'dealerId',
                    dealerCode: 'dealerCode',
                    dealerName: 'dealerName',
                    brandId: 'brandId',
                    brandCode: 'brandCode',
                    brandName: 'brandName',
                    saleStartDate: '2019-06-29T05:56:31Z',
                    saleEndDate: '2019-06-29T05:56:31Z',
                    repairValidityMileage: 1,
                    repairValidityPeriod: 1,
                    creatorName: 'creatorName201',
                    createTime: '2019-06-29T05:56:31Z'
                },
                {
                    id: 'id202',
                    warrantyPolicyId: 'warrantyPolicyId203',
                    rowVersion: 'rowVersion',
                    options: [
                        'update',
                        'abandon',
                        'enable'
                    ],
                    code: 'code204',
                    name: 'name205',
                    startTime: '2019-06-29T05:56:31Z',
                    status: 1,
                    warrantyPolicyType: 1,
                    warrantyMileage: 1,
                    warrantyMonth: 1,
                    dealerId: 'dealerId',
                    dealerCode: 'dealerCode',
                    dealerName: 'dealerName',
                    brandId: 'brandId',
                    brandCode: 'brandCode',
                    brandName: 'brandName',
                    saleStartDate: '2019-06-29T05:56:31Z',
                    saleEndDate: '2019-06-29T05:56:31Z',
                    repairValidityMileage: 1,
                    repairValidityPeriod: 1,
                    creatorName: 'creatorName206',
                    createTime: '2019-06-29T05:56:31Z'
                }
            ],
            pageIndex: null,
            pageSize: null,
            sort: null,
            totalElements: 50,
            totalPages: null
        }
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.get('/:id', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message',
        payload: {
            id: 'id207',
            warrantyPolicyType: 1,
            warrantyMileage: 1,
            warrantyMonth: 1,
            saleStartDate: '2019-06-29T05:56:31Z',
            saleEndDate: '2019-06-29T05:56:31Z',
            repairValidityMileage: 1,
            repairValidityPeriod: 1,
            vehicles: [
                {
                    id: 'id208',
                    productCategoryId: 'productCategoryId209',
                    productCategoryCode: 'productCategoryCode210',
                    vehicleProperty: 1,
                    vehicleId: 'vehicleId211',
                    vin: 'vin',
                    materials: [
                        {
                            id: 'id212',
                            partId: 'partId213',
                            partCode: 'partCode214',
                            partName: 'partName215',
                            partWarrantyCategoryId: 'partWarrantyCategoryId216',
                            partWarrantyCategoryCode: 'partWarrantyCategoryCode217',
                            partWarrantyCategoryName: 'partWarrantyCategoryName218',
                            warrantyDuration: 1,
                            warrantyMileage: 1,
                            remark: 'remark'
                        }
                    ]
                },
                {
                    id: 'id219',
                    productCategoryId: 'productCategoryId220',
                    productCategoryCode: 'productCategoryCode221',
                    vehicleProperty: 1,
                    vehicleId: 'vehicleId222',
                    vin: 'vin',
                    materials: [
                        {
                            id: 'id212',
                            partId: 'partId213',
                            partCode: 'partCode214',
                            partName: 'partName215',
                            partWarrantyCategoryId: 'partWarrantyCategoryId216',
                            partWarrantyCategoryCode: 'partWarrantyCategoryCode217',
                            partWarrantyCategoryName: 'partWarrantyCategoryName218',
                            warrantyDuration: 1,
                            warrantyMileage: 1,
                            remark: 'remark'
                        }
                    ]
                }
            ]
        }
    };
    res.json(data);
});
module.exports = router;
